<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layer/JQuery/jquery-3.1.1.min.js}" type="text/javascript" charset="UTF-8"></script>
    <link rel="stylesheet" th:href="@{/css/secondlevel.css}"/>
    <link rel="stylesheet" th:href="@{/css/secondright2.css}"/>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style type="text/css">

        .layui-table-tool {
            position: relative;
            z-index: 890;
            width: 97.9%;
            min-height: 35px;
            line-height: 30px;
            padding: 10px 15px;
            border-width: 0 0 1px;
        }

        .layui-btn + .layui-btn {
            margin-left: 20px;
        }

        .layui-btn-container .layui-btn {
            margin-top: 5px;
            margin-left: 10px;
            margin-bottom: 5px;
            margin-right: 10px;
        }

        .layui-table-tool-self {
            position: absolute;
            right: 60px;
            top: 10px;
        }
    </style>
</head>
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>

<div class="layui-table-tool">
    <div class="layui-table-tool-temp">
        <div class="layui-btn-container">
            <form th:action="@{/teacher}" method="get">
                <input type="submit" class="layui-btn layui-btn-sm" id="addTable" value="添加"></input>
            </form>
        </div>
    </div>
</div>
<table class="layui-table">
    <colgroup>
        <col width="200">
        <col width="200">
        <col width="200">
        <col width="150">
        <col width="150">
    </colgroup>
    <thead>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>所属类别</th>
        <th>发布日期</th>
        <th>工具</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="teacher:${teachers.list}">
        <td th:text="${teacher.getTid()}"></td>
        <td th:text="${teacher.getTname()}"></td>
        <td th:text="${teacher.getTalentName()}"></td>
        <td th:text="${teacher.getTdate()}"></td>
        <td>
            <a class="layui-btn layui-btn-xs" lay-event="edit"
               th:href="@{/teacher/}+${teacher.getTid()}">编辑</a>
            <button class="layui-btn layui-btn-danger layui-btn-xs deleteBtn" lay-event="del"
                    th:attr="del_uri=@{/teacher/}+${teacher.getTid()}">删除
            </button>
        </td>
    </tr>
    <form id="deleteTeacherForm" method="post">
        <input type="hidden" name="_method" value="delete"/>
    </form>
    </tbody>
</table>

<div class="midbox_3right">
    <span th:text="'共' + ${teachers.total} + '条'"></span>
    <span th:text="${teachers.pageNum} + '/' + ${teachers.pages}">1/1</span>
    <div class="midbox_3right_1">
        <div><a th:href="@{'/teachers/'+${1}}">首页</a></div>
        <div th:if="${teachers.hasPreviousPage}"><a th:href="@{'/teachers/'+${teachers.prePage}}" >上页</a></div>
        <div th:if="${teachers.hasNextPage}"><a th:href="@{'/teachers/'+${teachers.nextPage}}">下页</a></div>
        <div><a th:href="@{'/teachers/'+${teachers.pages}}">尾页</a></div>
    </div>
</div>

<script>
    $(".deleteBtn").click(function () {
        //删除当前员工的
        $("#deleteTeacherForm").attr("action", $(this).attr("del_uri")).submit();
        return false;
    });
</script>

</body>
</html>